use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\Rdbms\IDatabase;
+use MediaWiki\MediaWikiServices;
/**
* Special page which uses a ChangesList to show query results.
}
/**
- * Main execution point
- *
- * @param string $subpage
+ * @param string|null $subpage
*/
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
$out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
$out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
- $out->addJsConfigVars(
- 'wgRCFiltersChangeTags',
- $this->getChangeTagList()
- );
$out->addJsConfigVars(
'StructuredChangeFiltersDisplayConfig',
[
'wgStructuredChangeFiltersCollapsedPreferenceName',
static::$collapsedPreferenceName
);
-
- $out->addJsConfigVars(
- 'StructuredChangeFiltersLiveUpdatePollingRate',
- $this->getConfig()->get( 'StructuredChangeFiltersLiveUpdatePollingRate' )
- );
} else {
$out->addBodyClasses( 'mw-rcfilters-disabled' );
}
}
+ /**
+ * Get config vars to export with the mediawiki.rcfilters.filters.ui module.
+ *
+ * @param ResourceLoaderContext $context
+ * @return array
+ */
+ public static function getRcFiltersConfigVars( ResourceLoaderContext $context ) {
+ return [
+ 'RCFiltersChangeTags' => self::getChangeTagList( $context ),
+ 'StructuredChangeFiltersEditWatchlistUrl' =>
+ SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
+ ];
+ }
+
/**
* Fetch the change tags list for the front end
*
+ * @param ResourceLoaderContext $context
* @return array Tag data
*/
- protected function getChangeTagList() {
- $cache = ObjectCache::getMainWANInstance();
- $context = $this->getContext();
+ protected static function getChangeTagList( ResourceLoaderContext $context ) {
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
- $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage()->getCode() ),
+ $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage() ),
$cache::TTL_MINUTE * 10,
function () use ( $context ) {
$explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
// Sort by hits (disabled for now)
//arsort( $tagHitCounts );
+ // HACK work around ChangeTags::truncateTagDescription() requiring a RequestContext
+ $fakeContext = RequestContext::newExtraneousContext( Title::newFromText( 'Dwimmerlaik' ) );
+ $fakeContext->setLanguage( Language::factory( $context->getLanguage() ) );
+
// Build the list and data
$result = [];
foreach ( $tagHitCounts as $tagName => $hits ) {
ChangeTags::truncateTagDescription(
$tagName,
self::TAG_DESC_CHARACTER_LIMIT,
- $context
+ $fakeContext
),
'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
'hits' => $hits,
$out = $this->getOutput();
// Styles and behavior for the legend box (see makeLegend())
$out->addModuleStyles( [
+ 'mediawiki.interface.helpers.styles',
'mediawiki.special.changeslist.legend',
'mediawiki.special.changeslist',
] );